<!DOCTYPE html>
<html lang="en">

<head>
  <meta charset="UTF-8">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>Document</title>
</head>

<body>
  <script>

    function pushHistory() {
      var state = {
        title: "title",
        url: "#"
      };
      window.history.pushState(state, "title", "#xx");
    }
    window.addEventListener("popstate", function (e) {
      console.log(e);
      alert("我监听到了浏览器的返回按钮事件啦");//根据自己的需求实现自己的功能  
      debugger
    }, false);
    
    function openNew() {
      // window.open('https://www.baidu.com', '_blank');
      var newWindow = window.open('', '_blank');
      newWindow.location.href = 'http://www.baidu.com';
    }

  </script>
  <button onclick="pushHistory()">pushHistory</button>
  <button onclick="openNew()">打开新页面，仍在旧页面</button>

</body>

</html>